var baseJs = require("./base.js")
var openID = wx.getStorageSync('openID')
var time2 = baseJs.getCurrentTimeStr().datetime2//带时分秒
var time = baseJs.getCurrentTimeStr().datetime
var miniprogram_state = "formal"

// 申请退款卖家发信息
module.exports.tuikuan = function tuikuan(orderID, goodsname) {
  wx.request({
    url: "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + wx.getStorageSync('tokenData'),
    method: "POST",
    data: {
      touser: openID, //接收者的openid
      template_id: "eXtajLhQBdZsRJFjKy3tLKg2FIEeB4Z4ovz0dGQ2NKQ",//订阅模板id、
      miniprogram_state: miniprogram_state,//模式:开发者，体验者，用户
      page: "/packageA/myOrder2/myOrder2?type=1",//进入收到的订单页面
      data: { //模板内容
        character_string4: {
          value: orderID,//订单编号
        },
        thing2: {
          value: goodsname//退款商品
        },
        time7: {
          value: time2//申请时间
        },
      }
    },
    success: res => {
      console.log(res);
      console.log(openID);
    }
  })
}

// 同意退款给买家发信息
module.exports.tuikuanPass = function tuikuanPass(tuikuanMoney, tuikuanRes, goodsName) {
  wx.request({
    url: "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + wx.getStorageSync('tokenData'),
    method: "POST",
    data: {
      touser: openID, //接收者的openid
      template_id: "-qZkmzvBU9_9OypcJYz11eiin5rDfCCq6JGGLcCM2-4",//订阅模板id、
      miniprogram_state: miniprogram_state,//模式:开发者，体验者，用户
      page: "/packageA/myOrder/myOrder?type=1",//进入收到的订单页面
      data: { //模板内容
        amount1: {
          value: tuikuanMoney,//退款金额
        },
        phrase4: {
          value: tuikuanRes//退款结果
        },
        thing6: {
          value: goodsName//商品名称
        },
      }
    },
    success: res => {
      console.log(res);
    }
  })
}

// 发货提醒给买家发信息
module.exports.fahuo = function fahuo(BusinessAllName, ExpressNumber, shouhuoRenPhone, shouhuorenAddress) {
  wx.request({
    url: "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + wx.getStorageSync('tokenData'),
    method: "POST",
    data: {
      touser: openID, //接收者的openid
      template_id: "jfaQsjZRgn3nhewyN-jQGs95jGHKlCMvjPs4mx_dIMU",//订阅模板id、
      miniprogram_state: miniprogram_state,//模式:开发者，体验者，用户
      page: "/packageA/myOrder/myOrder?type=1",//进入小程序查看详情
      data: { //模板内容
        thing22: {
          value: BusinessAllName,//商家名称
        },
        date4: {
          value: time//发货时间
        },
        character_string13: {
          value: ExpressNumber//快递单号
        },
        phone_number17: {
          value: shouhuoRenPhone //收货人电话
        },
        thing8: {
          value: shouhuorenAddress//收货地址
        }
      }
    },
    success: res => {
      console.log(res);
    }
  })
}

// 支付邮费给卖家发送
module.exports.payYoufei = function payYoufei(youfei, goodsname) {
  wx.request({
    url: "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + wx.getStorageSync('tokenData'),
    method: "POST",
    data: {
      touser: openID, //接收者的openid
      template_id: "z3NLD_OWmR2BZzCK2QFuZc-MXDPe0jxAz2VL8tB35LM",//订阅模板id、
      miniprogram_state: miniprogram_state,//模式:开发者，体验者，用户
      page: "/packageA/myOrder2/myOrder2?type=1",//进入小程序查看详情
      data: { //模板内容
        amount5: {
          value: youfei,//邮费金额
        },
        thing3: {
          value: goodsname//商品名称
        },
        thing6: {
          value: "买家已支付邮费,请尽快发货"//
        }
      }
    },
    success: res => {
      console.log(res);
    }
  })
}

// 设置邮费给买家发送
module.exports.setYoufei = function setYoufei(youfei, goodsname) {
  wx.request({
    url: "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + wx.getStorageSync('tokenData'),
    method: "POST",
    data: {
      touser: openID, //接收者的openid
      template_id: "z3NLD_OWmR2BZzCK2QFuZc-MXDPe0jxAz2VL8tB35LM",//订阅模板id、
      miniprogram_state: miniprogram_state,//模式:开发者，体验者，用户
      page: "/packageA/myOrder/myOrder?type=1",//进入小程序查看详情
      data: { //模板内容
        amount5: {
          value: youfei,//邮费金额
        },
        thing3: {
          value: goodsname//商品名称
        },
        thing6: {
          value: "卖家已设置邮费，请前往支付"
        }
      }
    },
    success: res => {
      console.log(res);
    }
  })
}

// 新商户审核通过提醒
module.exports.shenhePass = function shenhePass() {
  wx.request({
    url: "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + wx.getStorageSync('tokenData'),
    method: "POST",
    data: {
      touser: openID, //接收者的openid
      template_id: "oRho5nar3sRFg5eOI4g8JwR_hkWrMxkhEcTGgb8DT28",//订阅模板id、
      miniprogram_state: miniprogram_state,//模式:开发者，体验者，用户
      page: "/pages/index/index",//进入小程序查看详情
      data: { //模板内容
        thing1: {
          value: "恭喜，您的资料已通过审核，开启易生活！",//温馨提示
        },
        date4: {
          value: time2//时间
        }
      }
    },
    success: res => {
      console.log(res);
    }
  })
}

// 缴纳保证码提醒
module.exports.payMa = function payMa() {
  wx.request({
    url: "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + wx.getStorageSync('tokenData'),
    method: "POST",
    data: {
      touser: openID, //接收者的openid
      template_id: "fCfE4sxDwCJm9IetQoNhaROAM1SLngHCZBokUWsYwRI",//订阅模板id、
      miniprogram_state: miniprogram_state,//模式:开发者，体验者，用户
      page: "/pages/index/index",//进入小程序查看详情
      data: { //模板内容
        thing5: {
          value: "恭喜，您已成功加入易易部落自由商家圈层！",//温馨提示
        },
        thing3: {
          value: time2//时间
        }
      }
    },
    success: res => {
      console.log(res);
    }
  })
}

